package com.boil.qz.safekavass.pojo;

import com.boil.util.Constants;

import java.util.Set;
import java.util.TreeSet;

/**
 * Created by ChenYong on 2017-07-31.
 * <br>
 * 子资源映射实体类。
 */
public class ResourceChildVo extends ResourceVo implements Comparable<ResourceChildVo> {
    /**
     * 子资源（为递归而设计）
     */
    private Set<ResourceChildVo> childs;

    // 普通初始化块
    {
        childs = new TreeSet<ResourceChildVo>();
    }

    /**
     * 默认构造器。
     */
    public ResourceChildVo() {
        super();
    }

    public Set<ResourceChildVo> getChilds() {
        return childs;
    }

    public void setChilds(Set<ResourceChildVo> childs) {
        this.childs = new TreeSet<ResourceChildVo>(childs);
    }

    @Override
    public int compareTo(ResourceChildVo o) {
        if ((this == null) || (o == null)) {
            return Constants.VALUE_0;
        }

        return this.getResourceOrder().compareTo(o.getResourceOrder());
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("ResourceChildVo{");
        sb.append("childs=").append(childs);
        sb.append(", id=").append(id);
        sb.append(", parentId=").append(parentId);
        sb.append(", resourceName='").append(resourceName).append('\'');
        sb.append(", resourceIcon='").append(resourceIcon).append('\'');
        sb.append(", resourceUrl='").append(resourceUrl).append('\'');
        sb.append(", resourceType=").append(resourceType);
        sb.append(", resourceLevel=").append(resourceLevel);
        sb.append(", resourceOrder=").append(resourceOrder);
        sb.append(", permissionCode='").append(permissionCode).append('\'');
        sb.append(", createTime='").append(createTime).append('\'');
        sb.append('}');
        return sb.toString();
    }
}